import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

let store = new Vuex.Store({
    // 1. state
    state:{
        user:{

        },
        shareInfo:{
            name:'',
            id:''
        },
        iosJsUrl:'',
        isAndroid:false,
        isLoading:false
    },

    getters:{

    },
    mutations:{
        SETUSERINFO: (state, data) => {
            Object.assign(state.user, data);
        },
        SETSHAREINFO: (state,data) => {
            Object.assign(state.shareInfo,data);
        },
        SET_WX_JS_URL:(state,data) => {
            Object.assign(state,data);
        },
        UPDATE_DEVICE: (state, data) => {
            state.isAndroid = data.isAndroid
        },
        UPDATE_LOADING_STATUS:(state,data) => {

        }
    },
    actions:{
        setUserInfo(store, user) {
            store.commit('SETUSERINFO', user);
        },
        setShareInfo(store,info) {
            store.commit('SETSHAREINFO',info);
        }
    }
});

export default store;